package ca.shojaei.mini_sat;

import java.util.*;

public class Model {

	public static final int DEF_STATES = 25;
	private HashMap<Integer,State> states;
	private int totalState = 0;
	private int currentStat = 0; 
	
	
	
	private State start;
	
	public Model(State start)
	{
		if(start == null)
			throw new NullPointerException("Added State is Empty");
		
		this.states = new HashMap<Integer,State>(DEF_STATES);
		this.start = start;
		states.put(start.getStateName(), start);
		setCurrentStat(start.getStateName());
		totalState++;
	}
	
	
	public void addState(State state)
	{
		//TODO: need exception handling
		if(state == null)
			throw new NullPointerException("Added State is Empty");
		
        states.put(state.getStateName(), state);
        totalState++;
        
	}
	

	public void setStart(int stateName)
	{
		start = states.get(stateName);
	}
	
	public State getStart()
	{
		return start;
	}


	public void setCurrentStat(int currentStat) {
		this.currentStat = currentStat;
	}


	public State getCurrentStat() {
		return states.get(currentStat);
	}
	
	public int getCurrentStateName()
	{
		return currentStat;
	}
	
	public void reSetVisit()
	{
		Collection<State> col = this.states.values();
		Iterator< State> it = col.iterator();
		
		while(it.hasNext())
		{
			it.next().setVisited(false);
		}
	}

}
